﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;

namespace STEM123
{
    public partial class CreateContent : PhoneApplicationPage
    {
        public CreateContent()
        {
            InitializeComponent();
            PageTitle.Text = StemDataModel.Term;
        }

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
        }

        private void onAudioTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (StemDataModel.QuestionForTerm != null)
            {
                NavigationService.Navigate(new Uri("/CreateContentAudio.xaml", UriKind.Relative));
            }
            else
            {
                DisplayQuestionSelectError();
            }
        }

        private void onVideoTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (StemDataModel.QuestionForTerm != null)
            {
                NavigationService.Navigate(new Uri("/CreateContentVideo.xaml", UriKind.Relative));
            }
            else
            {
                DisplayQuestionSelectError();
            }
        }

        private void onTextTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            if (StemDataModel.QuestionForTerm != null)
            {
                NavigationService.Navigate(new Uri("/CreateContentText.xaml", UriKind.Relative));
            }
            else
            {
                DisplayQuestionSelectError();
            }
        }

        private void listQuestions_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBoxItem item =(ListBoxItem) e.AddedItems[0];
            StemDataModel.QuestionForTerm = item.Content.ToString();
        }

        private void AddSlide(object sender, EventArgs e)
        {
            // Code to add slide
        }

        private void PlayPresentation(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/ViewPresentation.xaml", UriKind.Relative));   
        }

        private void PublishPresentation(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/PublishResults.xaml", UriKind.Relative));
        }

        #region Helper Funtions
        //<summary>Helper Functions
        //These funtions provide support for error message display for this screen and
        //other help for functionality within the screen
        //</summary>
        private void DisplayQuestionSelectError()
        {
            MessageBox.Show("Please Select an Question to answer with these slides");
        }
        #endregion
    }
}